package com.egoo.ticket.server.dao;

import com.egoo.ticket.server.pojo.dto.WorkOrderDto;
import com.egoo.ticket.server.pojo.dto.WorkOrderNodeDto;
import com.egoo.ticket.server.pojo.dto.WorkOrderSelectInputDto;
import com.egoo.ticket.server.pojo.entity.WorkOrder;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;

/**
 * @author Administrator
 */
@Repository
public interface WorkOrderDao {
	/**
	 * 创建
	 * @param workOrder
	 * @return
	 */
	Integer create(WorkOrder workOrder);

	/**
	 * TODO
	 * @param searchContent
	 * @param workOrderTypeName
	 * @param workOrderStatusId
	 * @param startTime
	 * @param endTime
	 * @param currentPage
	 * @param pageSize
	 * @return
	 */
	@Deprecated
	List<WorkOrder> select(@Param("searchContent") String searchContent,
                           @Param("workOrderTypeName") String workOrderTypeName, @Param("workOrderStatusId") Integer workOrderStatusId,
                           @Param("startTime") String startTime, @Param("endTime") String endTime,
                           @Param("currentPage") Integer currentPage, @Param("pageSize") Integer pageSize);

	/**
	 * 查询列表
	 * @param workOrderSelectInputDto
	 * @return
	 */
	List<WorkOrder> selectWorkOrderList(WorkOrderSelectInputDto workOrderSelectInputDto);

	/**
	 * 查询未关闭数
	 * @param workOrderTypeId
	 * @return
	 */
	Integer selectTotalNotCloseStatus(Long workOrderTypeId);

	/**
	 * 更新
	 * @param workOrder
	 * @return
	 */
	Integer updateWorkOrder(WorkOrder workOrder);

	/**
	 * 根据id查询
	 * @param workOrderId
	 * @return
	 */
	WorkOrder selectById(String workOrderId);
	/**
	 * TODO 根据sessionId获取工单信息
	 * @author: victor_tang
	 * @createtime: 2020/3/26 14:57
	 * @param searchMap 1
	 * @return: com.egoo.ews.service.vo.WorkOrder
	 */
	List<WorkOrder> selectWorkOrderInfoBySessionId(Map<String, Object> searchMap);

	/**
	 * 根据流程实例id查询
	 * @param processInstanceId
	 * @return
	 */
	WorkOrder selectByProcessInstanceId(@Param("processInstanceId") String processInstanceId);

	/**
	 * 通过sql拼接查询
	 * @param sql
	 * @return
	 */
	List<WorkOrder> selectBySql(@Param("sql") String sql);
	/**
	 * 通过sql拼接查询总数
	 * @param sql
	 * @return
	 */
	Long selectCountBySql(@Param("sql") String sql);


	/**
	 * TODO
	 * @param sql
	 * @return
	 */
	List<WorkOrder> executeSql(@Param("sql") String sql);

//	/**
//	 * 查询总数
//	 * @param sql
//	 * @return
//	 */
//	Integer selectTotalBySql(@Param("sql") String sql);

	/**
	 * 批量删除
	 * @param workOrderList
	 * @return
	 */
	Integer deleteBatch(List<WorkOrder> workOrderList);

	/**
	 * 通过流程实例id更新工单
	 * @param workOrder
	 * @return
	 */
	Integer updateByProcessInstanceId(WorkOrder workOrder);

	/**
	 * / 获取节点处理信息
	 * @param workOrderId
	 * @return
	 */
	List<WorkOrderNodeDto> getWorkOrderNodeDtoList(String workOrderId);

	/**
	 * / 根据工单类型id查询activit的流程实例id
	 * @param workOrderTypeId
	 * @return
	 */
	List<WorkOrder> getByWorkOrderTypeId(Long workOrderTypeId);

	/**
	 * 通过状态查询工单
	 * @param statusId
	 * @return
	 */
	List<WorkOrder> selectByStatusId(@Param("statusId") Integer statusId);

	/**
	 * 批量查询
	 * @param ids
	 * @return
	 */
	List<WorkOrder> selectWorkOrderListByIds(@Param("ids") List<String> ids);

	/**
	 * 通过工单id查询节点内容
	 * @param id
	 * @return
	 */
	WorkOrderNodeDto selectContentByWorkOrderId(Integer id);

	/**
	 * 通过工单id查询用户名
	 * @param id
	 * @return
	 */
	String selectUserNameById(Integer id);

	/**
	 * 通过状态查询工单类型
	 * @param statusId
	 * @return
	 */
	String selectWorkTypeByStatusId(Integer statusId);

	/**
	 * 查询流程实例id
	 * @param processInstanceId
	 * @return
	 */
	String selectProcessInstanceId(@Param("processInstanceId") String processInstanceId);


	/**
	 * 更新处理人
	 * @param workOrderDto
	 * @return
	 */
	Integer updateCurrentHandler(WorkOrderDto workOrderDto);

	/**
	 * 通过主键动态更新
	 * @param workOrder
	 * @return
	 */
	Integer updateByPrimaryKeySelective(WorkOrder workOrder);

	/**
	 * 通过节点ids查询
	 * @return
	 */
	List<WorkOrder> selectWorkOrderTypeNodeIds();

	/**
	 * 通过节点id更新处理人信息
	 * @param workOrder
	 * @return
	 */
	Integer updateHandlePersonInfoByNodeId(WorkOrder workOrder);

	/**
	 * 更新客户唯一标识
	 * @param hashMap
	 * @return
	 */
	Integer updateCustomIdentify(Map<String, String> hashMap);

	/**
	 * 获取签到地址
	 * @param id
	 * @return
	 */
	String selectSignInAddress(String id);

    Integer updateWorkOrderStatus(Map<String, Object> map);
}
